import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class ID {      // pripoji sa do DB a zsiti najvyssie cislo zapasu a vrati ho o 1 vacsie
 
		
	public static int vratMaxID(String nazovTab, String stlpec) throws SQLException{
		
		int max=0;
		
		Pripojenie.pripoj();
		Statement s = Pripojenie.conn.createStatement ();
		
		   s.executeQuery ("SELECT "+stlpec+" FROM "+nazovTab);
		   ResultSet rs = s.getResultSet ();
		   while (rs.next ())
		   {
		       int pom = rs.getInt (stlpec);
		       if (pom > max) max=pom;
		   }
		
		return max+1;
	}	
}
